const http = require('http');
const Koa = require('koa');
const path = require('path');
const serve = require('koa-static');
const Router = require('koa-router');
const views = require('koa-views');
const bodyParser = require('koa-bodyparser');

const indexRouter = require('./src/router/index');


const app = new Koa();
const router = new Router();

app
    .use(router.routes())
    .use(router.allowedMethods());



app.use(views(__dirname + '/src/views', {
    extension: 'html'
}));


app.use(serve(path.join(__dirname, '/src/static')));

app.use(bodyParser());




app.use(indexRouter.routes(), indexRouter.allowedMethods());


app.listen(8000,function () {
    console.log("服务已经启动！")
});